package com.sjy.pickphotos.pickphotos.luban;

import android.text.TextUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.List;

class Checker {
    private static List<String> format = new ArrayList();

    Checker() {
    }

    static boolean isImage(String path) {
        if (TextUtils.isEmpty(path)) {
            return false;
        } else {
            String suffix = path.substring(path.lastIndexOf(".") + 1, path.length());
            return format.contains(suffix.toLowerCase());
        }
    }

    static boolean isJPG(String path) {
        if (TextUtils.isEmpty(path)) {
            return false;
        } else {
            String suffix = path.substring(path.lastIndexOf("."), path.length()).toLowerCase();
            return suffix.contains("jpg") || suffix.contains("jpeg");
        }
    }

    static String checkSuffix(String path) {
        return TextUtils.isEmpty(path) ? ".jpg" : path.substring(path.lastIndexOf("."), path.length());
    }

    static boolean isNeedCompress(int leastCompressSize, String path) {
        if (leastCompressSize > 0) {
            File source = new File(path);
            if (!source.exists()) {
                return false;
            }

            if (source.length() <= (long)(leastCompressSize << 10)) {
                return false;
            }
        }

        return true;
    }

    static {
        format.add("jpg");
        format.add("jpeg");
        format.add("png");
        format.add("webp");
        format.add("gif");
    }
}